fix(code-review): refresh staged/unstaged diffs on index changes#2202
Merged
Conversation
External git operations (terminal `git add`, commits) write `.git/index` but the file watcher's `onGitStateChanged` handler only invalidated branch-related queries, leaving the cached `getDiffCached` and `getDiffUnstaged` results stale. The renderer kept showing the previous staged version even after the index changed. Also drop the `hasStagedFiles` gate on `getDiffCached` so the staged section appears/disappears in lockstep with the query result rather than racing against a separately-derived flag from `changedFiles`. Generated-By: PostHog Code Task-Id: 4d1b802b-2174-457f-84f1-6d969eab2e34
Contributor
|
Reviews (1): Last reviewed commit: "fix(code-review): refresh staged/unstage..." | Re-trigger Greptile |
jonathanlab
approved these changes
May 19, 2026
jonathanlab
approved these changes
May 19, 2026
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
git add, commits, etc.) write.git/indexbut the file watcher'sonGitStateChangedhandler only invalidated branch queries, so cachedgetDiffCachedandgetDiffUnstagedresults stayed stale. The Local Review viewer kept showing the previous staged version after staging through the terminal.hasStagedFilesgate ongetDiffCachedso the staged section appears/disappears in lockstep with the query result rather than racing the changed-files query (which is itself gated byisActivesince feat: virtualized and optimized diff rendering #2113).Repro before fix
fileX,git add fileX, then editfileXagain so it has both staged and unstaged changes.git add fileXfrom the terminal — viewer keeps showing the prior split instead of collapsing into a single combined staged diff.Test plan
pnpm dev, open a local repo taskgit add <file>in the terminal while the Review tab is open — the "Changes" section drops the file and "Staged Changes" updates to include the combined diff+in Changes panel) still workspnpm --filter code typecheckpassespnpm --filter code testpassesCreated with PostHog Code